// 数据传输手段 可读流 可写流
/**
 * 可读流
 */
const fs = require("fs");
//read stream
let rs = fs.createReadStream("./1.txt", {
  flags:'r',
  mode:0o666,
  start:1,
  end:9,
  highWaterMark: 3,
});
// watch data event, once start stream could read and send data
//  highWaterMark set size
rs.setEncoding('utf-8')
rs.on("data", (data) => {
  console.log(data);
  rs.pause() //暂停读取和发射
  setTimeout(function(){
    rs.resume()
  },2000)
});
rs.on("error", (err) => {
  console.log(err);
});
rs.on("end", () => {
  console.log("read over");
});
rs.on('open',()=>{
    console.log('file open');
})
rs.on('close',()=>{
    console.log('file close');
})
// flags mode start end encoding highwatermark 
